#include<bits/stdc++.h>

using namespace std;



int main()
{
    int n,k;cin>>n>>k;
    k%=n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];

    reverse(a,a+n);
    reverse(a,a+n-k);
    reverse(a+n-k,a+n);
    for(int i=0;i<n;i++)
        if(i==n-1)cout<<a[i];
    else
        cout<<a[i]<<" ";
    return 0;
}
